/*
 * Copyright ShangHai ECLUB Information Technology Co.,Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at

 * http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.eclub.emotion.rootstone.server.http.mapping;

import com.eclub.emotion.rootstone.server.http.HttpRequest;

/**
 * 
 * Abstract base class for URL-mapped 
 * {@link com.eclub.emotion.rootstone.server.http.mapping.HandlerMapping}
 * implementations.
 * @author   jun.yang, Wincor Nixdorf International GmbH
 */
public abstract class AbstractUrlHandlerMapping implements HandlerMapping{

	@Override
	public Object getHandler(HttpRequest request) throws Exception {
		Object handler = getHandlerInternal(request);
		if (handler == null) {
			return null;
		}
		if (handler instanceof String) {
			String handlerName = (String) handler;
			handler = null;
		}
		return getHandlerExecutionChain(handler, request);
	}
	
	
	protected Object getHandlerExecutionChain(Object handler, HttpRequest request) {
		return null;
	}
	
	/**
	 * Look up a handler for the given request, returning <code>null</code> if no
	 * specific one is found. This method is called by {@link #getHandler};
	 * @param request current RootStone HTTP Request
	 * @return the corresponding handler instance, or <code>null</code> if none found
	 * @throws  Exception if there is an internal error
	 */
	protected abstract Object getHandlerInternal(HttpRequest request) throws Exception;
	
	

}


